﻿using Automatic.Base;
using Automatic.Controls;
using Automatic.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Automatic.ViewModels
{
    class MainViewModel:NotifyBase
    {
        //private object _pageContent;

        //public object PageContent
        //{
        //    get { return _pageContent; }
        //    set { _pageContent = value; }
        //}
        private object _pageContent;

        public object PageContent
        {
            get { return _pageContent; }
            set { SetProperty(ref _pageContent,value); }
        }
        private string _total;

        public string Total
        {
            get { return _total; }
            set { SetProperty(ref _total, value); }
        }

        private string _productionCount;

        public string ProductionCount
        {
            get { return _productionCount; }
            set { SetProperty(ref _productionCount, value); }
        }

        private string _badCount;

        public string BadCount
        {
            get { return _badCount; }
            set { SetProperty(ref _badCount, value); }
        }

        public List<MonitorItemModel> Evironment { get; set; }

        public List<MonitorItemModel> DeviceMonitor { get; set; }

        public List<AlarmItemModel> AlarmList { get; set; }

        public ObservableCollection<RaderSeriesModel> RaderDatas { get; set; }

        public List<PersonnelItemModel> PersonnelList { get; set; }

        public List<WorkshopItemModel> WorkshopList { get; set; }

        public MainViewModel()
        {
            Total = 197.ToString("0000");

            ProductionCount = 17147.ToString("00000");

            BadCount = 17.ToString("000");

            #region 初始化环境监控
            Evironment = new List<MonitorItemModel>();
            Evironment.Add(new MonitorItemModel() { Header="光照(Lux)"});
            Evironment.Add(new MonitorItemModel() { Header="噪音(db)"});
            Evironment.Add(new MonitorItemModel() { Header="温度(℃)"});
            Evironment.Add(new MonitorItemModel() { Header= "PM2.5(m³)" });
            Evironment.Add(new MonitorItemModel() { Header="硫化氢(ppm)"});
            Evironment.Add(new MonitorItemModel() { Header="氮气(ppm)"});
            #endregion

            #region 初始化报警消息列表
            AlarmList = new List<AlarmItemModel>();
            AlarmList.Add(new AlarmItemModel() { Num = "01", Message = "设备温度过高", Time = "2024-10-27 20:00:00", Len = 5 });
            AlarmList.Add(new AlarmItemModel() { Num = "02", Message = "车间温度过高", Time = "2024-10-27 20:00:00", Len = 5 });
            AlarmList.Add(new AlarmItemModel() { Num = "03", Message = "设备转速过高", Time = "2024-10-27 20:00:00", Len = 5 });
            #endregion

            #region 初始化设备监控
            DeviceMonitor = new List<MonitorItemModel>();
            DeviceMonitor.Add(new MonitorItemModel() { Header = "电能（Kw·h）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "电压（V）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "电流（A）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "压差（kpa）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "温度（℃）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "振动（mm/s）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "转速（r/min）", Value = 311.2 });
            DeviceMonitor.Add(new MonitorItemModel() { Header = "气压（kpa）", Value = 311.2 });
            #endregion

            #region 初始化雷达数据
            RaderDatas = new ObservableCollection<RaderSeriesModel>();

            Random rd = new Random();
            for (int i = 1; i <= 7; i++)
            {
                RaderDatas.Add(new RaderSeriesModel() { Header = $"tag{i}", Value = rd.Next(20, 100) });
            }
            #endregion

            #region 人员缺岗信息
            PersonnelList = new List<PersonnelItemModel>();
            PersonnelList.Add(new PersonnelItemModel() { Name = "张三", Duties = "技术员", ManHour = 212 });
            PersonnelList.Add(new PersonnelItemModel() { Name = "李四", Duties = "操作员", ManHour = 318 });
            PersonnelList.Add(new PersonnelItemModel() { Name = "王五", Duties = "工程师", ManHour = 250 });
            PersonnelList.Add(new PersonnelItemModel() { Name = "赵六", Duties = "质检员", ManHour = 68 });
            PersonnelList.Add(new PersonnelItemModel() { Name = "钱七", Duties = "管理员", ManHour = 123 });
            #endregion

            #region 初始化车间列表
            WorkshopList = new List<WorkshopItemModel>(); ;
            WorkshopList.Add(new WorkshopItemModel() { Name = "贴片车间", TotalCount = 45, WorkCount = 32, WaitCount = 8, FaultCount = 0 });
            WorkshopList.Add(new WorkshopItemModel() { Name = "封装车间", TotalCount = 45, WorkCount = 32, WaitCount = 8, FaultCount = 0 });
            WorkshopList.Add(new WorkshopItemModel() { Name = "焊接车间", TotalCount = 45, WorkCount = 32, WaitCount = 8, FaultCount = 0 });
            WorkshopList.Add(new WorkshopItemModel() { Name = "组装车间", TotalCount = 45, WorkCount = 32, WaitCount = 8, FaultCount = 0 });
            WorkshopList.Add(new WorkshopItemModel() { Name = "贴片车间", TotalCount = 45, WorkCount = 32, WaitCount = 8, FaultCount = 0 });
            #endregion
        }
    }
}
